// components/User_Posts/User_Posts.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    username:{
      type:String
    },
    content:{
      type:String
    },
    like:{
      type:Number,
      value:0
    },
    comment:{
      type:Number,
      value:0
    },
    pageTo:{
      type:String
    },
    postID:{
      type:Number,
      value:10
    },
    comID:{
      type:Number,
      value:1
    },
    realComID:{
      type:Number
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    islike:0,
    src_xihuan:"../../pages/icon/xihuan01.png"
  },
 

  /**
   * 组件的方法列表
   */
  methods: {

    likeNum(e){
      // console.log(e.currentTarget.dataset)
  
      if(this.data.islike % 2 == 0){
        var src_xihuan = "../../pages/icon/aixin.png"
        this.setData({
          like : this.data.like+ 1,
          islike :1,
          src_xihuan:src_xihuan
        })
      }
      else{
        var src_xihuan = "../../pages/icon/xihuan01.png"
        this.setData({
          like : this.data.like- 1,
          islike:0,
          src_xihuan:src_xihuan
        })

       
      }
//给数据库传更新信息
      const that = this
      wx.request({
        url: 'http://49.233.35.127/Wx/comment/update',
        method:"POST",
        data:{
          ID:that.data.postID,
          LikeNum:that.data.like,
          CommentNum:that.data.comment
        }
      })     
      console.log("评论详情的数据修改",this.data.like,this.data.postID) 
    },
   
  }
})
